package com.ai.module.suno.domain.bo;

import com.alibaba.fastjson2.JSONObject;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import org.springframework.beans.BeanUtils;

import java.util.List;

/**
 * @author: heJinQin
 * @create: 2024-04-27 01:32
 * @description:
{
       "id": "a5824a91-6cec-4869-abf6-87da01e353c5",
       "video_url": "https://cdn1.suno.ai/a5824a91-6cec-4869-abf6-87da01e353c5.mp4",
       "audio_url": "https://cdn1.suno.ai/a5824a91-6cec-4869-abf6-87da01e353c5.mp3",
       "image_url": "https://cdn1.suno.ai/image_a5824a91-6cec-4869-abf6-87da01e353c5.png",
       "image_large_url": "https://cdn1.suno.ai/image_large_a5824a91-6cec-4869-abf6-87da01e353c5.png",
       "is_video_pending": false,
       "major_model_version": "v3",
       "model_name": "chirp-v3",
       "metadata": {
           "tags": "mellow hip hop",
           "prompt": "",
           "gpt_description_prompt": null,
           "audio_prompt_id": "b72e5b54-ba38-4e41-9788-b77d218e360a",
           "history": [
               {
                   "id": "b72e5b54-ba38-4e41-9788-b77d218e360a",
                   "continue_at": 110.0
               }
           ],
           "concat_history": null,
           "type": "gen",
           "duration": 34.0,
           "refund_credits": false,
           "stream": true,
           "error_type": null,
           "error_message": null
       },
       "is_liked": false,
       "user_id": "9cf1cf7d-cc58-427f-a12e-72d826ae7453",
       "display_name": "RedHotRiff706",
       "handle": "redhotriff706",
       "is_handle_updated": false,
       "is_trashed": false,
       "reaction": null,
       "created_at": "2024-04-24T18:18:59.067Z",
       "status": "complete",
       "title": "test-自定义",
       "play_count": 0,
       "upvote_count": 0,
       "is_public": false
   }
 **/
@Data
public class SunoInfo {

    private String id;

    @JsonProperty("video_url")
    private String videoUrl;

    @JsonProperty("audio_url")
    private String audioUrl;

    @JsonProperty("image_url")
    private String imageUrl;

    @JsonProperty("image_large_url")
    private String imageLargeUrl;

    @JsonProperty("is_video_pending")
    private Boolean isVideoPending;

    @JsonProperty("major_model_version")
    private String majorModelVersion;

    @JsonProperty("model_name")
    private String modelName;

    @JsonProperty("metadata")
    private SunoMetadata metadata;

    @JsonProperty("is_liked")
    private  boolean isLiked;

    @JsonProperty("continue_at")
    private String continueAt;

    @JsonProperty("reaction")
    private String reaction;

    @JsonProperty("created_at")
    private String createdAt;

    private String status;

    @JsonProperty("title")
    private String title;

    @JsonProperty("play_count")
    private int playCount;

    @JsonProperty("upvote_count")
    private int upvoteCount;

    @JsonProperty("is_public")
    private int isPublic;

    @Data
    private class SunoMetadata {

        private String tags;

        private String prompt;

        @JsonProperty("gpt_description_prompt")
        private String gptDescriptionPrompt;

        @JsonProperty("audio_prompt_id")
        private String audioPromptId;

        private List<SunoHistory> history;

        @JsonProperty("concat_history")
        private String concatHistory;

        private String type;

        @JsonProperty("error_type")
        private String errorType;

        @JsonProperty("error_message")
        private String errorMessage;
    }

    @Data
    public static class SunoHistory {

        private String id;

        @JsonProperty("continue_at")
        private String continueAt;
    }

    public static void main(String[] args) {
        String str ="{\n" +
                "       \"id\": \"a5824a91-6cec-4869-abf6-87da01e353c5\",\n" +
                "       \"video_url\": \"https://cdn1.suno.ai/a5824a91-6cec-4869-abf6-87da01e353c5.mp4\",\n" +
                "       \"audio_url\": \"https://cdn1.suno.ai/a5824a91-6cec-4869-abf6-87da01e353c5.mp3\",\n" +
                "       \"image_url\": \"https://cdn1.suno.ai/image_a5824a91-6cec-4869-abf6-87da01e353c5.png\",\n" +
                "       \"image_large_url\": \"https://cdn1.suno.ai/image_large_a5824a91-6cec-4869-abf6-87da01e353c5.png\",\n" +
                "       \"is_video_pending\": false,\n" +
                "       \"major_model_version\": \"v3\",\n" +
                "       \"model_name\": \"chirp-v3\",\n" +
                "       \"metadata\": {\n" +
                "           \"tags\": \"mellow hip hop\",\n" +
                "           \"prompt\": \"\",\n" +
                "           \"gpt_description_prompt\": null,\n" +
                "           \"audio_prompt_id\": \"b72e5b54-ba38-4e41-9788-b77d218e360a\",\n" +
                "           \"history\": [\n" +
                "               {\n" +
                "                   \"id\": \"b72e5b54-ba38-4e41-9788-b77d218e360a\",\n" +
                "                   \"continue_at\": 110.0\n" +
                "               }\n" +
                "           ],\n" +
                "           \"concat_history\": null,\n" +
                "           \"type\": \"gen\",\n" +
                "           \"duration\": 34.0,\n" +
                "           \"refund_credits\": false,\n" +
                "           \"stream\": true,\n" +
                "           \"error_type\": null,\n" +
                "           \"error_message\": null\n" +
                "       },\n" +
                "       \"is_liked\": false,\n" +
                "       \"user_id\": \"9cf1cf7d-cc58-427f-a12e-72d826ae7453\",\n" +
                "       \"display_name\": \"RedHotRiff706\",\n" +
                "       \"handle\": \"redhotriff706\",\n" +
                "       \"is_handle_updated\": false,\n" +
                "       \"is_trashed\": false,\n" +
                "       \"reaction\": null,\n" +
                "       \"created_at\": \"2024-04-24T18:18:59.067Z\",\n" +
                "       \"status\": \"complete\",\n" +
                "       \"title\": \"test-自定义\",\n" +
                "       \"play_count\": 0,\n" +
                "       \"upvote_count\": 0,\n" +
                "       \"is_public\": false\n" +
                "   }";
        SunoInfo jsonObject = JSONObject.parseObject(str, SunoInfo.class);
        SunoInfo sunoInfo = new SunoInfo();
        BeanUtils.copyProperties(jsonObject,sunoInfo);
        System.out.println("sunoInfo = " + sunoInfo);
        System.out.println("jsonObject = " + jsonObject);

    }

}
